import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: 路由配置项
 *
 * hidden: true                   // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true               // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect           // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'             // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * meta : {
    roles: ['admin','editor']    // 设置该路由进入的权限，支持多个权限叠加
    title: 'title'               // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'             // 设置该路由的图标，对应路径src/icons/svg
    breadcrumb: false            // 如果设置为false，则不会在breadcrumb面包屑中显示
  }
 */

// 公共路由
export const constantRoutes = [{
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [{
      path: '/redirect/:path(.*)',
      component: (resolve) => require(['@/views/redirect'], resolve)
    }]
  },
  {
    path: '/login',
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/error/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/error/401'], resolve),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [{
      path: 'index',
      component: (resolve) => require(['@/views/index'], resolve),
      name: '首页',
      meta: {
        title: '首页',
        icon: 'dashboard',
        noCache: true,
        affix: true
      }
    }]
  },
  {
    path: '/commodity',
    component: Layout,
    hidden: true,
    children: [{
      path: 'category',
      component: (resolve) => require(['@/views/commodity/category/index'], resolve),
      name: 'category',
      meta: {
        title: '商品分类',
        icon: 'user'
      }
    }, {
      path: 'category/form',
      component: (resolve) => require(['@/views/commodity/category/form'], resolve),
      name: 'categoryForm',
      meta: {
        title: '分类详情',
        icon: 'user'
      }
    }, {
      path: "physical",
      component: (resolve) => require(['@/views/commodity/physical/index'], resolve),
      name: 'physical',
      meta: {
        title: '实物商品管理',
        icon: 'user'
      }
    }, {
      path: "physical/form",
      component: (resolve) => require(['@/views/commodity/physical/form'], resolve),
      name: 'physicalForm',
      meta: {
        title: '实物商品详情',
        icon: 'user'
      }
    }, {
      path: "service",
      component: (resolve) => require(['@/views/commodity/service/index'], resolve),
      name: 'service',
      meta: {
        title: '服务商品管理',
        icon: 'user'
      }
    }, {
      path: "service/form",
      component: (resolve) => require(['@/views/commodity/service/form'], resolve),
      name: 'serviceForm',
      meta: {
        title: '服务商品管理',
        icon: 'user'
      }
    }, {
      path: "advertise",
      component: (resolve) => require(['@/views/commodity/advertise/index'], resolve),
      name: 'proadvertise',
      meta: {
        title: '广告商品管理',
        icon: 'user'
      }
    }, {
      path: "advertise/form",
      component: (resolve) => require(['@/views/commodity/advertise/form'], resolve),
      name: 'proadvertiseForm',
      meta: {
        title: '广告商品详情',
        icon: 'user'
      }
    }, {
      path: "attribute",
      component: (resolve) => require(['@/views/commodity/tag/index'], resolve),
      name: 'attribute',
      meta: {
        title: '标签管理',
        icon: 'user'
      }
    }]
  },
  {
    path: '/stock',
    component: Layout,
    hidden: true,
    children: [{
      path: 'list',
      component: (resolve) => require(['@/views/stock/list/index'], resolve),
      name: 'stocklist',
      meta: {
        title: '库存列表',
        icon: 'user'
      }
    }, {
      path: 'warehouse',
      component: (resolve) => require(['@/views/stock/warehousing/index'], resolve),
      name: 'warehouse',
      meta: {
        title: '入库管理',
        icon: 'user'
      }
    }, {
      path: 'warehouse/form',
      component: () => import('@/views/stock/warehousing/form'),
      meta: {
        title: '入库管理',
        icon: 'user'
      }
    }, {
      path: 'rejected',
      component: (resolve) => require(['@/views/stock/rejected/index'], resolve),
      name: 'rejected',
      meta: {
        title: '退货管理',
        icon: 'user'
      }
    }, {
      path: 'rejected/form',
      component: () => import('@/views/stock/rejected/form'),
      meta: {
        title: '退货单',
        icon: 'user'
      }
    }, {
      path: 'loss',
      component: (resolve) => require(['@/views/stock/loss/index'], resolve),
      name: 'loss',
      meta: {
        title: '损耗管理',
        icon: 'user'
      }
    }, {
      path: 'loss/form',
      component: () => import('@/views/stock/loss/form'),
      meta: {
        title: '报损单',
        icon: 'user'
      }
    }, {
      path: 'stockwarn',
      component: (resolve) => require(['@/views/stock/stockwarning/index'], resolve),
      name: 'stockwarn',
      meta: {
        title: '库存预警',
        icon: 'user'
      }
    }, {
      path: 'stockwarn/form',
      component: () => import("@/views/stock/stockwarning/form"),
      meta: {
        title: '入库单',
        icon: 'user'

      }
    }, {
      path: 'expire',
      component: (resolve) => require(['@/views/stock/expirewarning/index'], resolve),
      name: 'expire',
      meta: {
        title: '到期预警',
        icon: 'user'
      }
    }]
  },
  {
    path: '/warehouse',
    component: Layout,
    hidden: true,
    children: [{
      path: 'list',
      component: (resolve) => require(['@/views/warehouse/list/index'], resolve),
      name: 'warelist',
      meta: {
        title: '分仓列表',
        icon: 'user'
      }
    }, {
      path: 'list/form',
      component: (resolve) => require(['@/views/warehouse/list/form'], resolve),
      name: 'listform',
      meta: {
        title: '新增分仓',
        icon: "user"
      }
    }, {
      path: 'list/detail',
      component: (resolve) => require(['@/views/warehouse/list/detail'], resolve),
      name: 'listdetail',
      meta: {
        title: '分仓详情',
        icon: "user"
      }
    }, {
      path: 'personel',
      component: (resolve) => require(['@/views/warehouse/personnel/index'], resolve),
      name: 'personel',
      meta: {
        title: '配送人员',
        icon: 'user'
      }
    }, {
      path: 'print',
      component: (resolve) => require(['@/views/warehouse/printing/index'], resolve),
      name: 'print',
      meta: {
        title: '配送人员',
        icon: 'user'
      }
    }]
  },
  {
    path: '/dispatch',
    component: Layout,
    hidden: true,
    children: [{
      path: 'dispatch',
      component: (resolve) => require(['@/views/dispatch/index'], resolve),
      name: 'dispatch',
      meta: {
        title: '调度记录',
        icon: 'user'
      }
    }]
  },
  {
    path: '/product',
    component: Layout,
    hidden: true,
    children: [{
      path: 'product',
      component: (resolve) => require(['@/views/product/product/index'], resolve),
      name: 'product',
      meta: {
        title: '产品列表',
        icon: 'user'
      }
    }, {
      path: 'product/form',
      component: (resolve) => require(['@/views/product/product/form'], resolve),
      name: 'productForm',
      meta: {
        title: '产品详情',
        icon: 'user'
      }
    }, {
      path: 'brand',
      component: (resolve) => require(['@/views/product/brand/index'], resolve),
      name: 'brand',
      meta: {
        title: '品牌列表',
        icon: 'user'
      }
    },{
      path: 'supplier',
      component: (resolve) => require(['@/views/product/supplier/index'], resolve),
      name: 'supplier',
      meta: {
        title: '供应商列表',
        icon: 'user'
      }
    }, {
      path: 'supplier/form',
      component: (resolve) => require(['@/views/product/supplier/form'], resolve),
      name: 'supplierForm',
      meta: {
        title: '供应商详情',
        icon: 'user'
      }
    }]
  },
  {
    path: '/member',
    component: Layout,
    hidden: true,
    children: [{
      path: 'member',
      component: (resolve) => require(['@/views/member/index'], resolve),
      name: 'member',
      meta: {
        title: '会员管理',
        icon: 'user'
      }
    }, {
      path: 'member/detail',
      component: (resolve) => require(['@/views/member/detail'], resolve),
      name: 'memberDetail',
      meta: {
        title: '详细信息',
        icon: 'user'
      }
    }, {
      path: 'member/consume',
      component: (resolve) => require(['@/views/member/consume'], resolve),
      name: 'memberConsume',
      meta: {
        title: '消费订单详情',
        icon: 'user'
      }
    }, {
      path: 'member/coupon',
      component: (resolve) => require(['@/views/member/coupon'], resolve),
      name: 'memberCoupon',
      meta: {
        title: '优惠券详情',
        icon: 'user'
      }
    }]
  },
  {
    path: '/order',
    component: Layout,
    hidden: true,
    children: [{
      path: 'list',
      component: (resolve) => require(['@/views/order/list/index'], resolve),
      name: 'orderList',
      meta: {
        title: '订单列表',
        icon: 'user'
      }
    }, {
      path: 'list/detail',
      component: (resolve) => require(['@/views/order/list/detail'], resolve),
      name: 'orderDetail',
      meta: {
        title: '订单详情',
        icon: 'user'
      }
    }, {
      path: 'slrai',
      component: (resolve) => require(['@/views/order/slrai/index'], resolve),
      name: 'slrai',
      meta: {
        title: '订单维权',
        icon: 'user'
      }
    }, {
      path: 'slrai/detail',
      component: (resolve) => require(['@/views/order/slrai/detail'], resolve),
      name: 'slraiDetail',
      meta: {
        title: '订单维权详情',
        icon: 'user'
      }
    }]
  },
  {
    path: '/evaluate',
    component: Layout,
    hidden: true,
    children: [{
      path: 'evaluate',
      component: (resolve) => require(['@/views/evaluate/index'], resolve),
      name: 'evaluate',
      meta: {
        title: '评价列表',
        icon: 'user'
      }
    }, {
      path: "evaluate/detail",
      component: (resolve) => require(['@/views/evaluate/detail'], resolve),
      name: "evaluateDetail",
      meta: {
        title: "评价详情",
        icon: "user"
      }
    }]
  },
  {
    path: '/group',
    component: Layout,
    hidden: true,
    children: [{
      path: 'list',
      component: (resolve) => require(['@/views/group/list/index'], resolve),
      name: 'groupList',
      meta: {
        title: '拼团列表',
        icon: 'user'
      }
    }, {
      path: 'list/form',
      component: (resolve) => require(['@/views/group/list/form'], resolve),
      name: 'groupForm',
      meta: {
        title: '团购商品详情',
        icon: 'user'
      }
    }, {
      path: 'infomanage',
      component: (resolve) => require(['@/views/group/infomanage/index'], resolve),
      name: 'infomanage',
      meta: {
        title: '拼团信息管理',
        icon: 'user'
      }
    }, {
      path: 'infomange/detail',
      component: (resolve) => require(['@/views/group/infomanage/detail'], resolve),
      name: 'infomanageDetail',
      meta: {
        title: '拼团信息详情',
        icon: 'user'
      }
    }, {
      path: 'infomanage/detail/order',
      component: () => import('@/views/group/infomanage/order'),
      meta: {
        title: "拼团订单详情",
        icon: "user"
      }
    }, {
      path: 'setting',
      component: (resolve) => require(['@/views/group/setting/index'], resolve),
      name: 'setting',
      meta: {
        title: '拼团设置',
        icon: 'user'
      }
    }]
  },
  {
    path: '/coupon',
    component: Layout,
    hidden: true,
    children: [{
      path: 'manage',
      component: (resolve) => require(['@/views/coupon/manage/index'], resolve),
      name: 'coumanage',
      meta: {
        title: '优惠券列表',
        icon: 'user'
      }
    }, {
      path: "manage/form",
      component: (resolve) => require(['@/views/coupon/manage/form'], resolve),
      name: 'manageForm',
      meta: {
        title: '优惠券详情',
        icon: 'user'
      }
    }, {
      path: "grant",
      component: (resolve) => require(['@/views/coupon/grant/index'], resolve),
      name: 'grant',
      meta: {
        title: '发放优惠券',
        icon: 'user'
      }
    }, {
      path: "record",
      component: (resolve) => require(['@/views/coupon/record/index'], resolve),
      name: 'record',
      meta: {
        title: '领券记录',
        icon: 'user'
      }
    }]
  },
  {
    path: '/activity',
    component: Layout,
    hidden: true,
    children: [{
      path: 'model',
      component: (resolve) => require(['@/views/activity/model/index'], resolve),
      name: 'activityModel',
      meta: {
        title: '活动列表',
        icon: 'user'
      }
    }, {
      path: "model/form",
      component: (resolve) => require(['@/views/activity/model/form'], resolve),
      name: 'activityModelForm',
      meta: {
        title: '活动详情',
        icon: 'user'
      }
    }, {
      path: "goods",
      component: (resolve) => require(['@/views/activity/goods'], resolve),
      name: 'activityGoods',
      meta: {
        title: '活动商品',
        icon: 'user'
      }
    }, {
      path: "goods/form",
      component: (resolve) => require(['@/views/activity/goods/form'], resolve),
      name: 'activityGoodsForm',
      meta: {
        title: '商品详情',
        icon: 'user'
      }
    }]
  },
  {
    path: '/advertice',
    component: Layout,
    hidden: true,
    children: [{
      path: 'advertice',
      component: (resolve) => require(['@/views/advertice/index'], resolve),
      name: 'advertice',
      meta: {
        title: '广告列表',
        icon: 'user'
      }
    }, {
      path: "advertice/form",
      component: (resolve) => require(['@/views/advertice/form'], resolve),
      name: 'adverticeForm',
      meta: {
        title: '广告详情',
        icon: 'user'
      }
    }]
  },
  {
    path: '/logistics',
    component: Layout,
    hidden: true,
    children: [{
      path: 'model',
      component: (resolve) => require(['@/views/logistics/model/index'], resolve),
      name: 'logmodel',
      meta: {
        title: '快递模板',
        icon: 'user'
      }
    }, {
      path: 'model/form',
      component: (resolve) => require(['@/views/logistics/model/form'], resolve),
      name: 'modelForm',
      meta: {
        title: '模板详情',
        icon: 'user'
      }
    }, {
      path: 'samecity',
      component: (resolve) => require(['@/views/logistics/samecity/index'], resolve),
      name: 'samecity',
      meta: {
        title: '同城配送',
        icon: 'user'
      }
    }, {
      path: 'setageing',
      component: (resolve) => require(['@/views/logistics/setageing/index'], resolve),
      name: 'setageing',
      meta: {
        title: '时效设置',
        icon: 'user'
      }
    }]
  },
  {
    path: '/finance',
    component: Layout,
    hidden: true,
    children: [{
      path: 'survey',
      component: (resolve) => require(['@/views/finance/survey/index'], resolve),
      name: 'survey',
      meta: {
        title: '订单概况',
        icon: 'user'
      }
    }, {
      path: 'cost',
      component: (resolve) => require(['@/views/finance/cost/index'], resolve),
      name: 'cost',
      meta: {
        title: '成本统计',
        icon: 'user'
      }
    }, {
      path: 'income',
      component: (resolve) => require(['@/views/finance/income/index'], resolve),
      name: 'income',
      meta: {
        title: '收入统计',
        icon: 'user'
      }
    }, {
      path: 'consume',
      component: (resolve) => require(['@/views/finance/consume/index'], resolve),
      name: 'consume',
      meta: {
        title: '消费排行榜',
        icon: 'user'
      }
    }, {
      path: 'delivery',
      component: (resolve) => require(['@/views/finance/delivery/index'], resolve),
      name: 'delivery',
      meta: {
        title: '配送数据',
        icon: 'user'
      }
    }, {
      path: 'finance',
      component: (resolve) => require(['@/views/finance/finance/index'], resolve),
      name: 'finance',
      meta: {
        title: '毛利统计',
        icon: 'user'
      }
    }, {
      path: 'market',
      component: (resolve) => require(['@/views/finance/market/index'], resolve),
      name: 'market',
      meta: {
        title: '销售排行榜',
        icon: 'user'
      }
    }, {
      path: 'inventory',
      component: (resolve) => require(['@/views/finance/inventory/index'], resolve),
      name: 'inventory',
      meta: {
        title: '数据盘点',
        icon: 'user'
      }
    }]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [{
      path: 'profile',
      component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
      name: 'Profile',
      meta: {
        title: '个人中心',
        icon: 'user'
      }
    }]
  },
  {
    path: '/dict',
    component: Layout,
    hidden: true,
    children: [{
      path: 'type/data/:dictId(\\d+)',
      component: (resolve) => require(['@/views/system/dict/data'], resolve),
      name: 'Data',
      meta: {
        title: '字典数据',
        icon: ''
      }
    }]
  },
  {
    path: '/job',
    component: Layout,
    hidden: true,
    children: [{
      path: 'log',
      component: (resolve) => require(['@/views/monitor/job/log'], resolve),
      name: 'JobLog',
      meta: {
        title: '调度日志'
      }
    }]
  },
  {
    path: '/gen',
    component: Layout,
    hidden: true,
    children: [{
      path: 'edit/:tableId(\\d+)',
      component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
      name: 'GenEdit',
      meta: {
        title: '修改生成配置'
      }
    }]
  }
]

export default new Router({
  mode: 'hash', // 去掉url中的#
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})
